<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class  CreateUsersTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('users', function (Blueprint $table) {
            $table->id()->comment('用户表');
            $table->string('account',32)->nullable()->comment('用户账号')->index();
            $table->integer('system_admin_id')->default(1)->comment('管理员账号')->index();
            $table->string('password')->comment('用户密码');
            $table->string('real_name',25)->nullable()->comment('用户真实姓名');
            $table->integer('sex')->nullable()->comment('用户性别 0:男 1:女');
            $table->string('birthday',32)->nullable()->comment('用户生日');
            $table->string('card_id',20)->nullable()->comment('用户身份证号码');
            $table->string('nickname',60)->nullable()->comment('用户昵称');
            $table->string('avatar')->default('a.png')->comment('用户头像');
            $table->string('email')->nullable()->comment('用户邮箱');
            $table->char('phone',15)->nullable()->comment('用户手机号码');
            $table->integer('level')->default(1)->comment('用户等级')->index();
            $table->decimal('balance',8,2)->default('0.00')->comment('用户余额');
            $table->string('addres')->nullable()->comment('用户详细地址');
            $table->string('country')->default(0)->comment('用户所属国家 0:中国 1:外国');
            $table->integer('integral')->nullable()->comment('用户剩余积分');
            $table->tinyInteger('status')->default(1)->comment('用户状态 0:禁用 1:正常')->index();
            $table->integer('group_id')->nullable()->comment('用户分组id')->index();
            $table->string('remark')->nullable()->comment('用户备注');
            $table->integer('partner_id')->nullable()->comment('合伙人id');
            $table->integer('label_id')->nullable()->comment('标签id');
            $table->integer('sign_num')->default(1)->comment('连续签到天数');
            $table->string('last_ip',20)->nullable()->comment('最后一次登录ip');
            $table->timestamp('last_time')->nullable()->comment('最后一次登录时间');
            $table->integer('pay_count')->nullable()->comment('用户购买次数');
            $table->decimal('brokerage_price',8,2)->nullable()->comment('佣金金额');
            $table->decimal('experience',8,2)->default(1)->comment('用户经验');
            $table->string('user_type',50)->nullable()->comment('用户类型 (officialAccount:微信公众号, applet:微信小程序,h5:H5,pc:PC,app:APP)');
            $table->string('login_type',50)->nullable()->comment('用户登录类型 (h5:移动端,wechat:微信,Pc:电脑端)');
            $table->string('is_promoter')->default(0)->comment('是否为推广员 0:普通用户 1:推广员')->index();
            $table->tinyInteger('is_extension')->default(0)->comment('是否具有推广资格 0:没有资格 1:有资格');
            $table->integer('promoter_id')->nullable()->comment('推广员id');
            $table->timestamp('promoter_time')->nullable()->comment('推广员关联时间');
            $table->integer('spread_count')->nullable()->comment('下级人数');
            $table->integer('admin_id')->nullable()->comment('管理员id');
            $table->char('record_phone',15)->nullable()->comment('记录临时电话');
            $table->tinyInteger('is_member')->default(0)->comment('是否为会员 0:非会员 1:会员');
            $table->timestamp('member_time')->nullable()->comment('会员到期时间');
            $table->string('member_source')->nullable()->comment('会员来源 purchasegoods:购买商品 spendmoney:花钱购买 membercard:会员卡领取');
            $table->tinyInteger('is_forever_member')->default(0)->comment('是否是永久会员 0:非永久会员 1:永久会员');
            $table->string('uniqid',32)->nullable()->comment('唯一标识');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('users');
    }
}
